<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Tenplate</title>

    <style>
        .active
        {
            color: red;    
        }
    </style>

</head>
<body>

<div id="app">
    <!-- <h2 class="active">{{message}}</h2> -->
    <!-- <h2 :class="active">{{message}}</h2> -->

    <!-- <h2 v-bind:class="{key1 : value1, key2 : value2}">{{message}}</h2> -->
    <!-- 为true添加类名 为false不添加 -->
    <!-- <h2 v-bind:class="{类名1 : true or false, 类名2 : boolean}">{{message}}</h2> -->

    <h2 :class="{active : isActive, line : isLine}">{{message}}</h2>
    
    <!-- 绑定methods方法 -->
    <h2 :class="getClass()">{{message}}</h2>
    
    <button v-on:click="change">颜色切换</button>

</div>

<script src="../js/vue.js"></script>
<script>
    const app = new Vue
    (
        {
            el : "#app",
            data : 
            {
                message : "hello",
                active : 'active',
                isActive : true,
                isLine : true,
            },
            methods : 
            {
                change : function ()
                {
                    this.isActive = !this.isActive;
                },
                getClass : function ()
                {
                    return {active :this.isActive, line : this.isLine};
                }
            }
        }
    )
</script>
    
</body>
</html>